﻿@model IEnumerable<ToWaTimeReportMVC4.Models.UserProjectWrapper>
@{
    ToWaTimeReportMVC4.Models.ToWaService service = new ToWaTimeReportMVC4.Models.ToWaService();
    ToWaTimeReportMVC4.Models.User user = service.GetUserByUsername(User.Identity.Name);
    if (user != null)
    {
        if (user.Type == 0)
        {
@section featured {
    <section class="featured">
    <div class="content-wrapper">
        <hgroup class="title">
            <h1>Admin Profile</h1>
        </hgroup>
    </div>
</section>
}
<table title="Users" cellpadding="2">
    <tr>
        <th>Username</th>
        <th>Type</th>
    </tr>
@{
            foreach (var item in Model)
            {
                if (item.user != null)
                {
            <tr>
                <td>@Html.Label(item.user.Username)</td>
                <td>@Html.Label(service.GetTypeOfUserByUsername(item.user.Username))</td>
                <td>@Html.ActionLink("Delete User", "DeleteUser", new { id = item.user.Id })</td>
            </tr>
                }
            }
}
</table>
@Html.ActionLink("Create User", "CreateUser", "Admin")
<hr />
<table title="Projects" cellpadding="2">
    <tr>
        <th>Project name</th>
        <th>Description</th>
        <th>Owner</th>
    </tr>
@{
            foreach (var item in Model)
            {
                if (item.project != null)
                {
            <tr>
                <td>@Html.Label(item.project.Name)</td>
                <td>@Html.Label(item.project.Description)</td>
                <td>@Html.Label(item.project.User.Username)</td>
                <td>@Html.ActionLink("Delete Project", "DeleteProject", new { id = item.project.Id })</td>
            </tr>
                }
            }
}
</table>
@Html.ActionLink("Create Project", "CreateProject", "Admin")
@Html.ActionLink("Search Rapports", "SearchRapport", "Admin")
        }
        else
        {
            <p>Permission denied!</p>
        }
    }
}
